package org.java.pay.conf;

import org.java.pay.interceptor.PayInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-2-22 0022 上午 10:13
 * 这是webmvc的配置类，标识，在请求进入web的时候，先进入拦截器
 */
//标识为配置类
@Configuration
public class PayWebConf implements WebMvcConfigurer {
    //注入拦截器
    @Autowired
    private PayInterceptor payInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器,并且添加访问路径，在任何请求下都进入拦截器
        registry.addInterceptor(payInterceptor).addPathPatterns("/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
